from PySide6.QtCore import Signal, Slot, qDebug
from PySide6.QtWidgets import QDialog
from Forms.darenContactDialogForm import darenContactDialogForm
from Libs import Excel
from . import *
import time


class DarenContactDialog(QDialog):
    darenContact = Signal(dict)
    download = Signal(dict)
    closeSignal = Signal()

    def __init__(self, parentWidget=None):
        super().__init__()

        self.parentWidgets = parentWidget
        self.mainUi = darenContactDialogForm()
        self.mainUi.setupUi(self)

        qDebug(f"contactModel in DarenContactDialog: {self.parentWidgets.contactMode}")
        qDebug(f"darens in DarenContactDialog: {self.parentWidgets.darens}")
        self.time = int(time.time())

        # self.mainUi.buttonBox.accepted.connect(self.downloadContactInfo)
        # self.mainUi.buttonBox.rejected.connect(self.closeDialog)
        self.mainUi.downloadButton.clicked.connect(self.downloadContactInfo)
        self.mainUi.cancelButton.clicked.connect(self.closeDialog)

        self.downloadBody = {
            # 测试专用，写1
            # 'page_size': 1,
            # 暂时写死100
            'page_size': 100,
            # 'page_size': self.parentWidgets.contactLimit,
            'page': 1,
            'order': 'id',
            'sort': 'desc',
            'contact_status': 0
        }
        self.downloadRes = []

    def closeDialog(self):
        self.closeSignal.emit()

    def downloadContactInfo(self):
         self.download.emit(self.downloadBody)

    def getDarenContact(self):
         qDebug('getDarenContactgetDarenContact')

    @Slot(dict)
    def updateDownloadProgress(self, data):
        pass
